package org.ch02.entity;

/**
 * 实体对象 - 基于反射实现一些测试操作
 *
 * 修饰符 - Modifier
 */
public class Student {
    /**
     * 属性 - 字段Field
     */
    private String name;
    private int age;
    private float weight;
    private static final double PI = 3.14;

    /**
     * 构造方法 - Constructor
     */
    public Student() {
    }
    public Student(String name, int age, float weight) {
        this.name = name;
        this.age = age;
        this.weight = weight;
    }

    public Student(String name, Float weight) {
        this.name = name;
        this.age = 18;
        this.weight = weight;
    }
    private Student(String name) {
        this.name = name;
        this.age = 18;
        this.weight = 100;
    }
    public Student(String name, int age, Double weight) {
        this.name = name;
        this.age = age;
        this.weight = Float.parseFloat(String.valueOf(weight));
    }
    /**
     * 方法 - Method
     */
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public float getWeight() {
        return weight;
    }

    public void setWeight(float weight) {
        this.weight = weight;
    }

    public void hello() {
        System.out.println("你好!");
    }

    private String sleep(String address,int hour) {
        System.out.printf("睡觉了！地点：%s,时长：%s",address,hour);
        return "你好";
    }

    public void sayHello(String who) {
        System.out.println("你好," + who);
    }
    public void sayHello(String who,int age) {
        System.out.println("你好," + who+";年龄"+age);
    }

    public int sum(int i, int j) {
        return i + j;
    }

    @Override
    public String toString() {
        return this.getName()+","+this.getAge()+","+this.getWeight() ;
    }

    /**
     * 静态方法
     */
    public static void study(){
        System.out.println("学习！");
    }
    public static void study(String sth){
        System.out.printf("学习%s！",sth);
    }

    /**
     * 输出对象信息
     */
    public void show(){
        System.out.printf("姓名: %s,年龄: %d,身高: %.2f,PI: %s",name,age,weight,PI);
    }
}